﻿
Partial Class Default3
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = Request.ServerVariables("Local_addr")
        Dim serverDB As SYS.DAO.sysServerDAO = New SYS.DAO.sysServerDAO("telecom")
        serverDB.TryLock(Request.ServerVariables("Local_addr"), Session.SessionID)
        checkLock()

        TextBox1.Text = Now.ToString("yyyy/MM/dd HH:mm:ss.ff")

        System.Threading.Thread.Sleep(80 * 1000)
        serverDB.unLock(Session.SessionID)
        TextBox2.Text = Now.ToString("yyyy/MM/dd HH:mm:ss.ff")
        TextBox3.Text = Request.ServerVariables("Local_addr")

    End Sub
    Private Sub checkLock()
        Dim serverDB As SYS.DAO.sysServerDAO = New SYS.DAO.sysServerDAO("telecom")
        For ii As Integer = 0 To 2400
            If serverDB.CheckLock(Request.ServerVariables("Local_addr"), Session.SessionID) Then
                System.Threading.Thread.Sleep(1000)
            Else
                Exit For
            End If

        Next
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'TextBox1.Text = Request.ServerVariables("Local_addr")
        'Dim serverDB As SYS.DAO.sysServerDAO = New SYS.DAO.sysServerDAO()
        'serverDB.TryLock(Request.ServerVariables("Local_addr"), Session.SessionID)
        'checkLock()

        'TextBox1.Text = Now.ToString("yyyy/MM/dd HH:mm:ss.ff")

        'System.Threading.Thread.Sleep(20 * 1000)
        'serverDB.unLock(Session.SessionID)
        'TextBox2.Text = Now.ToString("yyyy/MM/dd HH:mm:ss.ff")
        'TextBox3.Text = Request.ServerVariables("Local_addr")
        'TextBox1.Text = Now.ToString("yyyy/MM/dd HH:mm:ss")
        '
        'TextBox2.Text = Now.ToString("yyyy/MM/dd HH:mm:ss")
    End Sub

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox1.Text = Request.ServerVariables("Local_addr")
        Dim serverDB As SYS.DAO.sysServerDAO = New SYS.DAO.sysServerDAO("telecom")
        serverDB.TryLock(Request.ServerVariables("Local_addr"), Session.SessionID)
        'checkLock()

        TextBox1.Text = Now.ToString("yyyy/MM/dd HH:mm:ss.ff")

        System.Threading.Thread.Sleep(80 * 1000)
        serverDB.unLock(Session.SessionID)
        TextBox2.Text = Now.ToString("yyyy/MM/dd HH:mm:ss.ff")
        TextBox3.Text = Request.ServerVariables("Local_addr")
    End Sub
End Class
